$().ready(function(){
    //页面初始化
    console.log(1);

    function init(){
        getKitchenInfo();
    }
    init();
    imgUpload('imgInput','imgShow',function(res){
        console.log(res);
        document.getElementById('ImgUrl').value = res;
    });


    //获取厨房信息
    function getKitchenInfo(){
        getAjax(`${global.apiUrl}/get_kitchen_content`,res=>{
            console.log(res);
            $('#k_name').val(res.name);
            $('#k_phone').val(res.phone);
            $('#ImgUrl').val(res.head_img);
            let img = `<img src="${res.head_img}" />`
            $('#imgShow').html(img);
        },{
            id:global.kitchen_id
        })
    }
    //修改厨房信息
    function setKitchenInfo(){
        let name = $('#k_name').val();
        let phone = $('#k_phone').val();
        let head_img = $('#ImgUrl').val();
        let pro = {
            id:global.kitchen_id,
            name:name,
            phone:phone,
            head_img:head_img
        }
        pro = JSON.stringify(pro);
        getAjax(`${global.apiUrl}/admin_save_community_service_kitchen_content`,res=>{
            console.log(res);
            if(res==1){
                alert('信息提交成功');
            }
        },{
            pro:pro
        })
    }
    $('#submit_btn').on('click',function () {
        setKitchenInfo();
    })
})
